package oldFiles;

public class TravelVector {

	private float length;
	private float angle;

	public TravelVector(float length, float angle)
	{
		this.length = length;
		this.angle = angle;
	}
	public float getLength()
	{
		return length;
	}
	
	public float getAngle()
	{
		return angle;
	}
	
	public void AddVector(TravelVector tv)
	{
		
		float x1 = this.length * (float)Math.cos(this.angle);
		float y1 = this.length * (float)Math.sin(this.angle);
		
		float x2 = tv.length * (float)Math.cos(tv.angle);
		float y2 = tv.length * (float)Math.sin(tv.angle);
		
		float x = x1 + x2;
		float y = y1 + y2;
		
		this.angle = (float)Math.atan(y/x);
		this.length = (float)Math.pow(x*x + y*y,0.5); 
	}

	public void SubstractVector(TravelVector tv)
	{
		
		float x1 = this.length * (float)Math.cos(this.angle);
		float y1 = this.length * (float)Math.sin(this.angle);
		
		float x2 = tv.length * (float)Math.cos(tv.angle);
		float y2 = tv.length * (float)Math.sin(tv.angle);
		
		float x = x1 - x2;
		float y = y1 - y2;
		
		this.angle = (float)Math.atan(y/x);
		this.length = (float)Math.pow(x*x + y*y,0.5); 
	}
}
